Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding the fetch size for a Query #327

Merged
merged 2 commits into from
Jul 22, 2018

Conversation

Pwootage
Copy link
Contributor

At lest in PostgreSQL, the result set from a select() does not appear to be fetched lazily, and PostgreSQL seems to be caching the entire ResultSet.

MyTable.select { ... }.forEach { ... }

image

After this change,

MyTable.select { ... }.fetchSize(1000).forEach { ... }

screen shot 2018-06-25 at 5 47 59 pm

In this test case case, it reduces memory usage by approximately 1.3gb.

This allows true lazy loading of a ResultSet
@Tapac
Copy link
Contributor

Tapac commented Jun 28, 2018

Hello, thank you for PR, we'll merge it soon, but don't you think that it's worth to add the possibility to provide default fetchSize for all queries and keep the ability to override it on single Query?

For example, add a parameter on Database instance?

@Pwootage
Copy link
Contributor Author

It probably would make sense to set a default - but I'm not sure what that default should be. PostgreSQL itself defaults to 0, which means "cache the entire response".

@Tapac Tapac merged commit d903802 into JetBrains:master Jul 22, 2018
Tapac pushed a commit that referenced this pull request Sep 29, 2018
* Allow overriding the fetch size for a Query
* Allow setting default fetch size in Database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants